home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / basic / dialogic.zip / EXAMPLE4.BAS < prev    next >
BASIC Source File  |  1990-01-31  |  7KB  |  165 lines

  1. '
  2. '┌───────────────────────────────────────────────────────┐
  3. '│ Written by Jonathan S. Waldman                        │
  4. '│ (C) 1989, 1990 Jonathan S. Waldman & Dialog Software  │
  5. '│ (C) Crescent Software.                                │
  6. '│ All rights reserved.                                  │
  7. '└───────────────────────────────────────────────────────┘
  8.  
  9. '============
  10. 'DiaLogic
  11. 'EXAMPLE4.BAS
  12. '============
  13.  
  14. '$INCLUDE: 'DIALOGIC.BI'         'include our DiaLogic TYPE definitions
  15.  
  16. '====================
  17. 'Initialize the mouse
  18. '====================
  19.  
  20.    CALL InitMouse(There%)        'see if mouse and driver are there
  21.    IF There% THEN                'if yes then
  22.       CALL ShowCursor            'show the mouse
  23.       CALL TextCursor(0, 4)      'use this to insure mouse is always visible
  24.    END IF
  25.  
  26. '======
  27. 'Set-up
  28. '======
  29.  
  30.    CALL HideCursor               'hide the mouse cursor during CLS & PRINTs
  31.    WIDTH , 25                    'insure we're in 25-line mode
  32.    COLOR 15, 1
  33.    CLS                           'clear the screen
  34.  
  35.  
  36. '========================
  37. 'REDIM the arrays for now
  38. '========================
  39.  
  40.    '$DYNAMIC                     'make all arrays dynamic
  41.    MaxDBE = 20                   'use for our dimension statements
  42.                                  '  20 dialog box elements will be our max
  43.    REDIM SHARED DB(2, MaxDBE) AS DialogType  'REDIM these TYPE arrays
  44.    REDIM SHARED LB(0) AS DialogText          '  dynamically
  45.  
  46. '=======================================
  47. 'Define some convenient string variables
  48. '=======================================
  49.  
  50.    PRINT
  51.    PRINT "   This is an example of stacked dialog boxes.  Choose <Help> to see this."
  52.    PRINT "   The <Help> message is displayed on top of the Find dialog box.  When"
  53.    PRINT "   the help is acknowledged, it is removed from the display and the Find"
  54.    PRINT "   dialog box is restored with all previous selections intact.  DiaLogic"
  55.    PRINT "   automatically preserves underlying information when Level% is > 1."
  56.    PRINT "   Notice that, unlike Example1, the Find dialog box is NOT regenerated"
  57.    PRINT "   but rather is re-activated.  In other words, in stacked dialog boxes the"
  58.    PRINT "   underlying dialog box is never removed from the screen."
  59.    PRINT
  60.  
  61.    CALL ShowCursor               'show it again
  62.  
  63.    Cancel$ = CHR$(27)            'these are our string assignments, also used
  64.    Help$ = CHR$(0) + CHR$(59)    '  in the FIND.DB template.
  65.    OK$ = CHR$(13)
  66.  
  67.    REDIM SHARED DB(2, MaxDBE) AS DialogType  'REDIM these TYPE arrays
  68.                                  'this example requires 2 Levels in DB()
  69.    REDIM SHARED LB(10) AS DialogText
  70.  
  71.    Level% = 1                    'set Level% to 1 for the Find dialog box
  72.    '$INCLUDE: 'FIND.DB'          'include the Find dialog box template
  73.    Action% = 1                   'set Action% to 1
  74.                                  'display the dialog box
  75.    CALL DiaLogic(DB(), LB(), Action%, Focus%, Ky$)
  76.    Action% = 3                   'get ready for polling
  77.    DO
  78.       Focus% = 0                 'set the input focus to auto -- 0
  79.       CALL DiaLogic(DB(), LB(), Action%, Focus%, Ky$)
  80.       IF Count% = 75 OR TIMER - OldTime! > .5 THEN
  81.          OldTime! = TIMER
  82.          LOCATE 19, 13, 0
  83.          COLOR 1, 7
  84.      CALL HideCursor
  85.          PRINT TIME$;
  86.          CALL ShowCursor
  87.          Count% = 0
  88.          COLOR 15, 1             'restore color to white on blue
  89.       END IF
  90.       IF Action% = 4 THEN
  91.          SELECT CASE Ky$
  92.  
  93.             CASE Help$              '<Help> was selected
  94.  
  95.                Level% = 2           'make Level% = 2 for stacking a Help message
  96.                '$INCLUDE: 'FINDH.DB''include Help dialog box template
  97.                Action% = 0          'set Action% to 0 so Help is automatically
  98.                                     '  removed from the screen
  99.                Focus% = 0           'set the input focus to auto -- 0
  100.                CALL DiaLogic(DB(), LB(), Action%, Focus%, Ky$)
  101.                Action% = 2          'refresh the Find dialog box
  102.                CALL DiaLogic(DB(), LB(), Action%, Focus%, Ky$)
  103.                Action% = 3          'prepare Find to be re-activated
  104.  
  105.             CASE OK$
  106.  
  107.                '=====================================
  108.                'Remove the dialog box from the screen
  109.                '=====================================
  110.  
  111.                Action% = 5
  112.                CALL DiaLogic(DB(), LB(), Action%, Focus%, Ky$)
  113.  
  114.                '=================================
  115.                'Store the Find dialog box results
  116.                '=================================
  117.              
  118.                Level% = 1                          'insure that the Level is
  119.                                                    '   correct
  120.  
  121.                Search$ = MID$(DB(Level%, 2).TextString, 1, DB(Level%, 2).NumberOne)
  122.                                                    'Search$ holds our search
  123.                                                    '   string
  124.                MatchCase = DB(Level%, 3).Default   '-1 if Match Case is checked
  125.                WholeWord = DB(Level%, 4).Default   '-1 if Whole Words is checked
  126.                SearchType = DB(Level%, 5).Default  ' 1 for Active Window, 2 for
  127.                                                    ' Current Module, or 3 for
  128.                                                    ' All Modules
  129.                '==============================
  130.                'Print the results to the user.
  131.                '==============================
  132.  
  133.                PRINT "   Your search string is " + LEFT$(Search$, 40) + " ..."
  134.                IF MatchCase THEN
  135.                   PRINT "   Match Upper/Lower Case was checked."
  136.                END IF
  137.                IF WholeWord THEN
  138.                   PRINT "   Whole Words Only was checked."
  139.                END IF
  140.                PRINT "   " + RTRIM$(MID$(DB(Level%, 5 + SearchType).Text, 5)) + " was selected."
  141.                ExitLoop = -1        'bail out
  142.  
  143.             CASE Cancel$
  144.  
  145.                '=====================================
  146.                'Remove the dialog box from the screen
  147.                '=====================================
  148.  
  149.                Action% = 5
  150.                CALL DiaLogic(DB(), LB(), Action%, Focus%, Ky$)
  151.  
  152.                ExitLoop = -1        'bail out
  153.  
  154.             CASE ELSE
  155.          END SELECT
  156.       END IF
  157.    LOOP UNTIL ExitLoop
  158.    COLOR 7, 0
  159.    CALL HideCursor
  160.    CLS
  161.  
  162.  
  163. END
  164.  
  165.